<?php
@include_once('conn.php');

$uid = $_GET['uid'];
$num = $_GET["num"];
$goodsid = $_GET["goodsid"];

$obj = [];

if ($uid && $num && $goodsid) {
    //根据uid更新
    $sql = "update cart_info set buynum = buynum+$num where userid ='$uid' and goodsid='$goodsid'";
    mysqli_query($conn, $sql);
    // 受影响的行数
    $rows = mysqli_affected_rows($conn);
    if ($rows > 0) {
        $obj['status'] = true;
        $obj['msg'] = '更新成功';
    } else {
        $obj['status'] = false;
        $obj['msg'] = '更新失败';
        $obj["sql"] = $sql;
    }
} else {
    $obj['status'] = false;
    $obj['msg'] = '前端数据有误';
    $obj["sql"] = $sql;
}

echo json_encode($obj);
